﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Cityship
{
    static class ShipBuilder
    {
        private static ContentManager _content;
        public static void Initialize(ContentManager content)
        {
            _content = content;
        }
        public static Deck CreateDeck(string deckImageLocation)
        {
            Texture2D shipImage = _content.Load<Texture2D>(deckImageLocation);
            Color[] shipData = new Color[shipImage.Width*shipImage.Height];
            Deck newDeck = new Deck(shipImage.Width, shipImage.Height);

            shipImage.GetData<Color>(shipData);

            int w = shipImage.Width;

            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < shipImage.Height; y++)
                {
                    if (shipData[(y * w) + x] == Color.Black)
                    {
                        newDeck.TileGrid[x, y] = new Tile(TileType.Floor, "default", new Point(x,y));
                        newDeck.TileGrid[x, y].HasFloor = true;
                        //newDeck.TileGrid[x, y].AirFlow += new Vector2(x - (w / 2), y - (shipImage.Height / 2))*-0.005f;
                    }
                    else
                    {
                        newDeck.TileGrid[x, y] = new Tile(TileType.Nothing, "default", new Point(x,y));
                    }
                }
            }
            newDeck.Outline();
            return newDeck;
        }
    }
}
